package com.power.sifa.std.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import com.power.sifa.std.model.Std_matter_attach_second;

import javax.transaction.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * 次级分类的申请所需材料 持久层(hibernate)
 */

public interface Std_matter_attach_secondDao extends JpaRepository<Std_matter_attach_second, Serializable>, JpaSpecificationExecutor<Std_matter_attach_second>, Repository<Std_matter_attach_second, Serializable>, Std_matter_attach_secondDaoCustom<Std_matter_attach_second, Serializable> {

   @Modifying
   @Transactional
   @Query("delete  from Std_matter_attach_second s where  s.id in (:ids) ")
   void removeByIds(@Param("ids") List<Integer> ids);

   @Query(value = "select stdattachid, min(require) as require from Std_matter_attach_second where matid = :matid and type in (:types) group by stdattachid", nativeQuery = true)
   List<Map> queryList(String matid, List<String> types);
}
